<!DOCTYPE html>
<html lang="en">





<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/favicon.png">
  <link rel="icon" type="image/png" href="/img/favicon.png">
  <meta name="viewport"
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="description" content="My Personal Website For Blog">
  <meta name="author" content="黄宇辉">
  <meta name="keywords" content="learning note,hexo blog">
  <title>Back up the Hexo blog - 欢迎参观小灰灰的网站哟 ヾ(◍°∇°◍)ﾉﾞ ~</title>

  <link  rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.4.1/css/bootstrap.min.css" />


  <link  rel="stylesheet" href="https://cdn.staticfile.org/github-markdown-css/4.0.0/github-markdown.min.css" />
  <link  rel="stylesheet" href="/lib/hint/hint.min.css" />

  
    <link  rel="stylesheet" href="https://cdn.staticfile.org/highlight.js/10.0.0/styles/vs2015.min.css" />
  

  


<!-- 主题依赖的图标库，不要自行修改 -->
<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_yg9cfy8wd6.css">

<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_pjno9b9zyxs.css">

<link  rel="stylesheet" href="/css/main.css" />

<!-- 自定义样式保持在最底部 -->


  <script  src="/js/utils.js" ></script>
</head>


<body>
  <header style="height: 70vh;">
    <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand"
       href="/">&nbsp;<strong>ANONYMOUS</strong>&nbsp;</a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                Home
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                Archives
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                Tags
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                About
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" data-toggle="modal" data-target="#modalSearch">&nbsp;&nbsp;<i
                class="iconfont icon-search"></i>&nbsp;&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

    <div class="view intro-2" id="background" parallax=true
         style="background: url('/img/default.png') no-repeat center center;
           background-size: cover;">
      <div class="full-bg-img">
        <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
          <div class="container text-center white-text fadeInUp">
            <span class="h2" id="subtitle">
              
            </span>

            
              
  <div class="mt-3 post-meta">
    <i class="iconfont icon-date-fill" aria-hidden="true"></i>
    <time datetime="2019-04-07 09:55">
      April 7, 2019 am
    </time>
  </div>


<div class="mt-1">
  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-chart"></i>
      968 字
    </span>
  

  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-clock-fill"></i>
      
      
      11
       分钟
    </span>
  

  
  
</div>

            
          </div>

          
        </div>
      </div>
    </div>
  </header>

  <main>
    
      

<div class="container-fluid">
  <div class="row">
    <div class="d-none d-lg-block col-lg-2"></div>
    <div class="col-lg-8 nopadding-md">
      <div class="container nopadding-md" id="board-ctn">
        <div class="py-5" id="board">
          <div class="post-content mx-auto" id="post">
            
            <article class="markdown-body">
              <h2 id="文章主题-备份及恢复Hexo博客的详细教程"><a href="#文章主题-备份及恢复Hexo博客的详细教程" class="headerlink" title="文章主题 : 备份及恢复Hexo博客的详细教程"></a>文章主题 : 备份及恢复<code>Hexo</code>博客的详细教程</h2><ul>
<li><em>备份原理: <code>master branch</code>: 管理<code>Hexo</code>生成的静态网页.  <code>HexoBackup branch</code>: 管理<code>Hexo 重要的本地源文件及配置文件.</code></em></li>
</ul>
<h3 id="前言-如果你利用Hexo搭建了一个静态的网站用于写博客-会发现自己利用Hexo-deploy的都是Hexo-generate生成的静态网页-而下面的目录并没有被push到远程仓库"><a href="#前言-如果你利用Hexo搭建了一个静态的网站用于写博客-会发现自己利用Hexo-deploy的都是Hexo-generate生成的静态网页-而下面的目录并没有被push到远程仓库" class="headerlink" title="前言 : 如果你利用Hexo搭建了一个静态的网站用于写博客,会发现自己利用Hexo deploy的都是Hexo generate生成的静态网页.而下面的目录并没有被push到远程仓库 !"></a>前言 : 如果你利用<code>Hexo</code>搭建了一个静态的网站用于写博客,会发现自己利用<code>Hexo deploy</code>的都是<code>Hexo generate</code>生成的静态网页.而下面的目录并没有被<code>push</code>到远程仓库 !</h3><ul>
<li><em>需要备份的目录及配置文件</em></li>
</ul>
<ol>
<li><code>source</code>目录 : 博客文章的<code>.md</code>文件.(需要备份)</li>
<li><code>themes</code> 目录 : 主题文件夹.(需要备份)</li>
<li><code>scaffolds</code>目录 : 文章的模板.(需要备份)</li>
<li><code>package.json</code> : 安装包的名称.(需要备份)</li>
<li><code>.gitignore</code> : 限定在<code>push</code>时哪些文件可以忽略.(需要备份)</li>
<li><code>_config.yml</code> : 站点的配置文件.(需要备份)</li>
</ol>
<ul>
<li><em>不需要备份的目录及配置文件</em></li>
</ul>
<ol>
<li><code>node_modules/</code> : 是安装包的目录，在执行<code>npm install</code>的时候会重新生成.(不需要备份)</li>
<li><code>.git/</code> : 主题和站点都有，标志这是一个git项目.(不需要备份)</li>
<li><code>public</code>是<code>hexo generate</code>生成的静态网页.(不需要备份)</li>
<li><code>.deploy_git</code> : 同<code>3</code>,<code>hexo g</code>也会生成.(不需要备份)</li>
<li><code>db.json</code> : 配置文件.(不需要备份)</li>
</ol>
<ul>
<li><em>注 : 不需要拷贝的文件正是<code>.gitignore</code>中所忽略的哟 !</em></li>
</ul>
<h3 id="备份"><a href="#备份" class="headerlink" title="备份"></a>备份</h3><ol>
<li>创建<code>GitHub</code>仓库<code>Username.github.io</code>如果同名仓库之前已经创建,请将之前的仓库改名,新建的仓库必须是<code>Username.github.io</code>.</li>
<li>在<code>Username.github.io</code>仓库中创建一个新的分支<code>HexoBackup</code>.(此时的默认分支是: <code>master</code>)</li>
<li>在该仓库中的<code>Setting</code>中将<code>HexoBackup</code>修改为为默认分支.</li>
<li>将刚刚创建的新仓库<code>clone</code>至本地后将之前你存放<code>Hexo bolg</code>文件夹中的<code>_config.yml</code>,<code>themes/</code>,<code>source/</code>,<code>scaffolds/</code>,<code>package.json</code>,<code>.gitignore</code>复制至你所<code>clone</code>下来的<code>Username.github.io</code>文件夹中.</li>
<li>将<code>themes/theme-name/</code>中的<code>.git/</code>删除,否则无法将主题文件夹<code>push</code>到远程分支.(<code>易错点 : 详情见文章最后的注意事项</code>)</li>
<li>在<code>Username.github.io</code>文件夹执行<code>npm install</code>和<code>npm install hexo-deployer-git</code>(注意: 此时在该文件内的分支名应该显示为:<code>HexoBackup</code>).</li>
<li>通过执行<code>git add .</code>,<code>git commit -m &quot;A description of the information submitted&quot;</code>,<code>git push origin HexoBackup</code>来提交<code>Hexo bolg</code>网站的源文件.</li>
<li>如果更新博客文章后可以通过执行<code>hexo g -d</code>生成静态网页部署到<code>Github</code>上.</li>
</ol>
<h3 id="更新-在本地对博客修改-包括修改主题样式-发布新文章等"><a href="#更新-在本地对博客修改-包括修改主题样式-发布新文章等" class="headerlink" title="更新( 在本地对博客修改: 包括修改主题样式,发布新文章等.. )"></a>更新( 在本地对博客修改: 包括修改主题样式,发布新文章等.. )</h3><ul>
<li><em>以下两个步骤没有严格的顺序,小伙伴们随心所欲呗 ~</em></li>
</ul>
<ol>
<li>首先执行<code>hexo g -d</code>生成静态网页部署至<code>Github</code>上.</li>
<li>其次依次执行<code>git add .</code>,<code>git commit -m &quot;&quot;</code>,<code>git push origin HexoBackup</code>来提交<code>Hexo bolg</code>网站源文件.</li>
</ol>
<h3 id="恢复-重装电脑后-或者在其它电脑上想修改自己的博客"><a href="#恢复-重装电脑后-或者在其它电脑上想修改自己的博客" class="headerlink" title="恢复 ( 重装电脑后,或者在其它电脑上想修改自己的博客.. )"></a>恢复 ( 重装电脑后,或者在其它电脑上想修改自己的博客.. )</h3><ol>
<li>安装<code>git</code>.</li>
<li>安装<code>Nodejs</code>和<code>npm</code>.</li>
<li>将博客仓库<code>clone</code>到本地.</li>
<li>在文件夹内执行命令<code>npm install hexo-cli -g</code>,<code>npm install</code>,<code>npm install hexo-deployer-git</code>.</li>
</ol>
<h3 id="注意事项-Hexo无法备份themes主题目录中的部分theme"><a href="#注意事项-Hexo无法备份themes主题目录中的部分theme" class="headerlink" title="注意事项 ( Hexo无法备份themes主题目录中的部分theme.. )"></a>注意事项 ( <code>Hexo</code>无法备份<code>themes</code>主题目录中的部分<code>theme</code>.. )</h3><ul>
<li><em>如果想正常备份你所喜欢的<code>theme</code>的话,可以在博客目录运行如下命令 :</em><div class="hljs"><pre><code class="hljs java">$ git rm --cached themes\theme-name\
rm <span class="hljs-string">'themes/theme-name'</span>

$ git status
On branch master
Your branch is up-to-date with <span class="hljs-string">'origin/HexoBackup'</span>.

Changes to be committed:
  (use <span class="hljs-string">"git reset HEAD &lt;file&gt;..."</span> to unstage)

        deleted:    themes/theme-name

Untracked files:
  (use <span class="hljs-string">"git add &lt;file&gt;..."</span> to include in what will be committed)

        themes/theme-name/

<span class="hljs-comment">//最后再执行: `git add themes/theme-name/` 就会发现可以成功备份该主题了哟 !</span></code></pre></div></li>
<li><strong>原因分析 : 这是因为用到了<code>git</code>的子模块(<code>git submodule</code>)功能,既你在你的<code>git</code>项目里<code>clone</code>的他人的项目.在你的主项目的<code>git</code>库里,子模块只是一个<code>HEAD</code>指针,指向子模块的<code>commit</code> ..详情见下述参考的博客文章哟 (っ•̀ω•́)っ✎⁾⁾</strong></li>
</ul>
<ul>
<li><em>参考博客文章如下( 甚是感谢 )</em> :</li>
<li><a href="https://blog.itswincer.com/posts/7efd2818/" target="_blank" rel="noopener">https://blog.itswincer.com/posts/7efd2818/</a></li>
<li><a href="https://hoxis.github.io/hexo-backup-theme-dir.html" target="_blank" rel="noopener">https://hoxis.github.io/hexo-backup-theme-dir.html</a></li>
</ul>

            </article>
            <hr>
            <div>
              <div class="post-metas mb-3">
                
                
                  <div class="post-meta">
                    <i class="iconfont icon-tags"></i>
                    
                      <a class="hover-with-bg" href="/tags/Hexo/">Hexo</a>
                    
                      <a class="hover-with-bg" href="/tags/github/">github_</a>
                    
                  </div>
                
              </div>
              
                <p class="note note-warning">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-sa/4.0/deed.zh" target="_blank" rel="nofollow noopener noopener">CC BY-SA 4.0 协议</a> ，转载请注明出处！</p>
              
              
                <div class="post-prevnext row">
                  <div class="post-prev col-6">
                    
                    
                      <a href="/2019/04/08/Java-Servlet-API/">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">Java Servlet API</span>
                        <span class="visible-mobile">Previous</span>
                      </a>
                    
                  </div>
                  <div class="post-next col-6">
                    
                    
                      <a href="/2019/04/06/Servlet-lifecycle/">
                        <span class="hidden-mobile">Servlet lifecycle</span>
                        <span class="visible-mobile">Next</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </div>
                </div>
              
            </div>

            
          </div>
        </div>
      </div>
    </div>
    
      <div class="d-none d-lg-block col-lg-2 toc-container" id="toc-ctn">
        <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;TOC</p>
  <div id="tocbot"></div>
</div>

      </div>
    
  </div>
</div>

<!-- Custom -->


    
  </main>

  
    <a id="scroll-top-button" href="#" role="button">
      <i class="iconfont icon-arrowup" aria-hidden="true"></i>
    </a>
  

  
    <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">Search</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v"
                 for="local-search-input">keyword</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>
  

  

  

  <footer class="mt-5">
  <div class="text-center py-3">
    <div>
      <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a>
      <i class="iconfont icon-love"></i>
      <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener">
        <span>Fluid</span></a>
    </div>
    
  <div class="statistics">
    
    

    
      
        <!-- 不蒜子统计PV -->
        <span id="busuanzi_container_site_pv" style="display: none">
            总访问量 
            <span id="busuanzi_value_site_pv"></span>
             次
          </span>
      
      
        <!-- 不蒜子统计UV -->
        <span id="busuanzi_container_site_uv" style="display: none">
            总访客数 
            <span id="busuanzi_value_site_uv"></span>
             人
          </span>
      
    
  </div>


    

    
  </div>
</footer>

<!-- SCRIPTS -->
<script  src="https://cdn.staticfile.org/jquery/3.4.1/jquery.min.js" ></script>
<script  src="https://cdn.staticfile.org/twitter-bootstrap/4.4.1/js/bootstrap.min.js" ></script>
<script  src="/js/debouncer.js" ></script>
<script  src="/js/main.js" ></script>

<!-- Plugins -->


  
    <script  src="/js/lazyload.js" ></script>
  



  <script defer src="https://cdn.staticfile.org/clipboard.js/2.0.6/clipboard.min.js" ></script>
  <script  src="/js/clipboard-use.js" ></script>



  <script defer src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script>





  <script  src="https://cdn.staticfile.org/tocbot/4.11.1/tocbot.min.js" ></script>
  <script>
    $(document).ready(function () {
      var boardCtn = $('#board-ctn');
      var boardTop = boardCtn.offset().top;

      tocbot.init({
        tocSelector: '#tocbot',
        contentSelector: 'article.markdown-body',
        headingSelector: 'h1,h2,h3,h4,h5,h6',
        linkClass: 'tocbot-link',
        activeLinkClass: 'tocbot-active-link',
        listClass: 'tocbot-list',
        isCollapsedClass: 'tocbot-is-collapsed',
        collapsibleClass: 'tocbot-is-collapsible',
        collapseDepth: 0,
        scrollSmooth: true,
        headingsOffset: -boardTop
      });
      if ($('.toc-list-item').length > 0) {
        $('#toc').css('visibility', 'visible');
      }
    });
  </script>



  <script  src="https://cdn.staticfile.org/typed.js/2.0.11/typed.min.js" ></script>
  <script>
    var typed = new Typed('#subtitle', {
      strings: [
        '  ',
        "Back up the Hexo blog&nbsp;",
      ],
      cursorChar: "_",
      typeSpeed: 70,
      loop: false,
    });
    typed.stop();
    $(document).ready(function () {
      $(".typed-cursor").addClass("h2");
      typed.start();
    });
  </script>



  <script  src="https://cdn.staticfile.org/anchor-js/4.2.2/anchor.min.js" ></script>
  <script>
    anchors.options = {
      placement: "right",
      visible: "hover",
      
    };
    var el = "h1,h2,h3,h4,h5,h6".split(",");
    var res = [];
    for (item of el) {
      res.push(".markdown-body > " + item)
    }
    anchors.add(res.join(", "))
  </script>



  <script  src="/js/local-search.js" ></script>
  <script>
    var path = "/local-search.xml";
    var inputArea = document.querySelector("#local-search-input");
    inputArea.onclick = function () {
      searchFunc(path, 'local-search-input', 'local-search-result');
      this.onclick = null
    }
  </script>



  <script  src="https://cdn.staticfile.org/fancybox/3.5.7/jquery.fancybox.min.js" ></script>
  <link  rel="stylesheet" href="https://cdn.staticfile.org/fancybox/3.5.7/jquery.fancybox.min.css" />

  <script>
    $('#post img:not(.no-zoom img, img[no-zoom]), img[zoom]').each(
      function () {
        var element = document.createElement('a');
        $(element).attr('data-fancybox', 'images');
        $(element).attr('href', $(this).attr('src'));
        $(this).wrap(element);
      }
    );
  </script>







  
  
    <script>
      !function (e, t, a) {
        function r() {
          for (var e = 0; e < s.length; e++) s[e].alpha <= 0 ? (t.body.removeChild(s[e].el), s.splice(e, 1)) : (s[e].y--, s[e].scale += .004, s[e].alpha -= .013, s[e].el.style.cssText = "left:" + s[e].x + "px;top:" + s[e].y + "px;opacity:" + s[e].alpha + ";transform:scale(" + s[e].scale + "," + s[e].scale + ") rotate(45deg);background:" + s[e].color + ";z-index:99999");
          requestAnimationFrame(r)
        }

        function n() {
          var t = "function" == typeof e.onclick && e.onclick;
          e.onclick = function (e) {
            t && t(), o(e)
          }
        }

        function o(e) {
          var a = t.createElement("div");
          a.className = "heart", s.push({
            el: a,
            x: e.clientX - 5,
            y: e.clientY - 5,
            scale: 1,
            alpha: 1,
            color: c()
          }), t.body.appendChild(a)
        }

        function i(e) {
          var a = t.createElement("style");
          a.type = "text/css";
          try {
            a.appendChild(t.createTextNode(e))
          } catch (t) {
            a.styleSheet.cssText = e
          }
          t.getElementsByTagName("head")[0].appendChild(a)
        }

        function c() {
          return "rgb(" + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + ")"
        }

        var s = [];
        e.requestAnimationFrame = e.requestAnimationFrame || e.webkitRequestAnimationFrame || e.mozRequestAnimationFrame || e.oRequestAnimationFrame || e.msRequestAnimationFrame || function (e) {
          setTimeout(e, 1e3 / 60)
        }, i(".heart{width: 10px;height: 10px;position: fixed;background: #f00;transform: rotate(45deg);-webkit-transform: rotate(45deg);-moz-transform: rotate(45deg);}.heart:after,.heart:before{content: '';width: inherit;height: inherit;background: inherit;border-radius: 50%;-webkit-border-radius: 50%;-moz-border-radius: 50%;position: fixed;}.heart:after{top: -5px;}.heart:before{left: -5px;}"), n(), r()
      }(window, document);
    </script>
  














</body>
</html>
